package java122;

public class TestThrows {
    public static void computer() throws ArithmeticException{
        int x = (int) (1 + (Math.random() * 2));
        int y = (int) (Math.random() * 2);
        int result;
        result =x/y;
        System.out.println("the result is:"+result);
    }
    public static void exp(ArithmeticException e) {
        System.out.println("ArithmeticException 类的对象出现");
        e.printStackTrace();
    }
    public static void main(String[] args) {
        try {
            computer();
        }catch (ArithmeticException e) {
            exp(e);
        }finally {
            System.out.println("这是finally语句块");
        }
    }
}
